<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>

    // 查
    // console.log(typeof localStorage);
    // console.log(localStorage);
    // console.log(window.localStorage);
    // console.log(window.localStorage === localStorage);

    // console.log(localStorage.name)
    // console.log(localStorage.age)
    // console.log(localStorage.sex)

    // 增
    // localStorage.msg = "hello world";
    
    // 查
    // console.log(localStorage.msg);

    // 改
    // localStorage.name = "admin";

    // 删
    // delete localStorage.age;

    // 查
    // console.log(localStorage);

    // 不存在索引，undefined
    // console.log(localStorage[0]);

    // 数据个数
    // console.log(localStorage.length);

    // 遍历
    // for(let i in localStorage){
    //     console.log(i, localStorage[i]);
    // }

    // ==============
    
    console.log( localStorage.getItem("name") );
    console.log( localStorage.getItem("age") );
    
    localStorage.setItem("abc", 10);
    localStorage.setItem("name", "张三");
    localStorage.setItem("a", function(){});
    localStorage.setItem("b", undefined);
    localStorage.setItem("c", null);
    localStorage.setItem("d", NaN);
    localStorage.setItem("e", true);
    localStorage.setItem("f", {});
    localStorage.setItem("g", []);

    localStorage.removeItem("a");
    localStorage.removeItem("b");
    localStorage.removeItem("c");

    localStorage.clear();

    console.log(localStorage);
</script>
</html>